import 'package:flutter/material.dart';
import 'package:lovify/screens/tabs/chat_tab.dart';
import 'package:lovify/screens/tabs/home_tab.dart';
import 'package:lovify/screens/tabs/my_tab.dart';

class HomeScreen extends StatefulWidget {
  const HomeScreen({super.key});

  @override
  HomeScreenState createState() => HomeScreenState();
}

class HomeScreenState extends State<HomeScreen> {
  int _pos = 0;

  final List<Widget> _pages = [
    const HomeTab(),
    const ChatTab(),
    const MyTab(),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: IndexedStack(
        index: _pos,
        children: _pages,
      ),
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: _pos,
        backgroundColor: Colors.white,
        selectedItemColor: const Color(0xFFFF5D5B),
        unselectedItemColor: const Color.fromRGBO(217, 217, 217, 1),
        selectedLabelStyle: const TextStyle(fontWeight: FontWeight.bold),
        unselectedLabelStyle: const TextStyle(fontWeight: FontWeight.normal),
        type: BottomNavigationBarType.fixed,
        items: const [
          BottomNavigationBarItem(
            icon: Icon(Icons.home),
            label: '首页',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.chat),
            label: '沟通',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.person),
            label: '我的',
          ),
        ],
        onTap: (pos) {
          if (_pos != pos) {
            setState(() {
              _pos = pos;
            });
          }
        },
      ),
    );
  }
}
